"""
@author: ty
@file: 2022-11-04作业.py
@time: 2022/11/4 17:36
"""

# name = {"A":"1","B":"2","C":"3","D":"4","E":"5","F":"6"}
# gift = {}
# persons = list(name.keys())
# for k in persons:
#     flag = 0  # 标记自己带来的礼物是否还未分配出去
#     if k in name:
#         flag = 1
#
#         mygift = name.pop(k)  # 如果自己带来的礼物还未分配，则去掉该礼物
#
#         getgift = name.popitem()  # 随机返回并移除一对key-value值
#
#         gift= getgift[1]  # 得到的礼物
#
#     if flag:
#
#         name[k] = mygift  # 将自己的礼物添到未分配礼物中
#
#     print(gift)  # 输出礼物分配情况

# import random
#
# name = [['A', '1'], ['B', '2'], ['C', '3'], ['D', '4'], ['E', '5'], ['F', '6']]  # 存储参与者的姓名和自己带来的礼物
# gift = []  # 存储交换后的结果
# n = len(name)  # 参与人数
# gifts = [i[1] for i in name]  # 未分配出去的礼物
# for x in range(n):
#     flag = 0
#     person = name[x][0]
#     myGift = name[x][1]
#     if myGift in gifts:
#         flag = 1
#         gifts.remove(myGift)
#     getGift = random.choice(gifts)  # 随机分配礼物
#     name.append([person, getGift])
#     gifts.remove(getGift)
#     if flag:
#         gifts.append(myGift)
#
# print(name)




# import random
#
# students = ['L', 'S', 'Z', 'T', 'Y', 'G', 'C', 'X']
# leave = ['C']
# while len(students) != 0:
#     s = input("按任意键开始点名，按q退出")
#     if s != "q":
#         rand=random.choice(students)
#         if rand in leave:
#             print(f"{rand}同学请假")
#             students.remove(rand)
#         else:
#             print(f"请{rand}同学回答问题")
#             students.remove(rand)
#     else:
#         print("点名结束")
#         break
# else:
#     print("全部点过，点名结束")


# 菜单一
# 1.登录
# def login(username, passwd):
#     if username in user and user[username]['passwd'] == passwd:
#         return True
#
# # 2.注册
# def register(username, passwd, money):
#     if username in user:
#         print("用户名已存在，请重新输入！")
#     else:
#         user[username] = {'passwd':passwd, 'money':money}
#         print(f"{username}注册成功")
#         print("用户信息已更新".center(26,"-"))
#         print(f"{'用户名':<8}{'密码':<10}{'金额':<7}")
#         for i in user:      #逐个打印用户名、密码、金额
#             print(f"{i:<10}{user[i]['passwd']:<12}{user[i]['money']:<10}")
#
# # 菜单二
# # 1.查看商品信息
# def message():
#     print("商品信息".center(40,"-"))
#     print(f"{'商品编号':<7}{'商品名称':<8}{'单价':<7}")
#     for i in goodsmess:     #逐个打印商品编号、名称、单价
#         print(f"{i:<10}{goodsmess[i]['name']:<10}{goodsmess[i]['price']:<10}")
#     print("-"*44)
# def exit():
#     global cartmoney2
#     print("谢谢惠顾！欢迎下次光临！".center(30))
#     print("-"*38)
#     print(f"{'商品编号':<8}{'商品名称':<8}{'单价':<7}{'数量':<7}")
#     for i in cart2:
#         print(f"{i:<11}{goodsmess[i]['name']:<10}{goodsmess[i]['price']:<8}{cart2[i]:<10}")
#     print("-" * 38)
#     print(f"总共消费：{cartmoney2}，余额为：{user[username]['money']}")
#     cart2.clear()   #退出之后清空购物单
#     cartmoney2 = 0     #将总消费金额置0
#
# # 主程序
# user = {'root':{'passwd':'123456', 'money':100}}
# print("欢迎进入三乐购物系统".center(50,"-"))
# goodsmess = {'F01':{'name':'苹果','price':2},
#              'F02':{'name':'香蕉','price':2},
#              'F03':{'name':'梨子','price':1},
#              'F04':{'name':'芒果','price':2},
#              'F05':{'name':'柚子','price':8},
#              'F06':{'name':'西瓜','price':10}}
#
# cart = {}      #购物车，初始化为空
# cart2 = {}     #存放所有已购商品 --> 类似于购物车1+购物车2+...
# cartmoney = 0     #购物车消费金额  初始化为0
# cartmoney2 = 0    #所有的购物车消费金额
# while 1:
#     print("1、登录".center(50))
#     print("2、注册".center(50))
#     print("3、退出".center(50))
#     option = input("请输入你的选择：")
#     if option == '1':
#         username = input("请输入用户名：")
#         passwd = input("请输入密码：")
#         if login(username,passwd):
#             print("登录成功")
#             print(f"欢迎光临！你的余额为：{user[username]['money']}")
#             while 2:
#                 print("1、查看商品信息".center(50))
#                 option2 = input("请输入你的选择：")
#                 if option2 == '1':
#                     message()
#                     break
#         else:
#             print("登录失败")
#     elif option == '2':
#         username = input("请输入用户名：")
#         passwd = input("请输入密码：")
#         money = int(input("请输入金额："))
#         register(username,passwd,money)
#     elif option == '3':
#         print("退出")
#         break
#     else:
#         break























